//
//  TLAlertHelper.m
//  FunnyVideo
//
//  Created by 李鑫 on 15/9/20.
//  Copyright © 2015年 NewEggTech. All rights reserved.
//
#define GIFAlertNoneData @"GifAlertNoData"
#define GIFAlertNetBlock @"GifAlertNetBlock"
#define GIFAlertLoading @"GifAlertLoading"
#define GIFAlertSuccess  @"GifAlertSuccess"
#define GIFAlertUnknown  @"GifAlertUnknown"

#import "TLAlertHelper.h"
#import "LXActionSheet.h"



@interface TLAlertHelper ()<LXActionSheetDelegate>

@property (nonatomic,strong) ActionSheetBlock block;
@property (nonatomic,strong) LXActionSheet   *sheet;
@end

@implementation TLAlertHelper

+ (TLAlertHelper *)sharedHelper{
    static dispatch_once_t onceToken;
    static TLAlertHelper *helper = nil;
    dispatch_once(&onceToken, ^{
        helper = [[TLAlertHelper alloc] init];
    });
    
    
    return helper;
}

+ (void)showPopAlertWithString:(NSString *)alertStr{
    
}

+ (void)showGifAlert:(NSString *)gifFileName delay:(NSInteger)delay{
    dispatch_async(dispatch_get_main_queue(), ^{
        
    });
}

+ (void)showGifAlertType:(TLAlertType)alertType delay:(NSInteger)delay{
    dispatch_async(dispatch_get_main_queue(), ^{
        [GiFHUD setGifWithImageName:[TLAlertHelper gifFilePathWithGifAlertType:alertType]];
        [GiFHUD show];
    });
}

+ (void)showGifAlertType:(TLAlertType)alertType delay:(NSInteger)delay onSpecialView:(UIView *)spcView{
    dispatch_async(dispatch_get_main_queue(), ^{
        
    });
}
+ (void)dismissGIFHUD{
    dispatch_async(dispatch_get_main_queue(), ^{
        [GiFHUD dismiss];
    });
}
+ (void)showSuccessHUDWithText:(NSString *)alertText{
    dispatch_async(dispatch_get_main_queue(), ^{
    [ProgressHUD showSuccess:alertText];
    });
}

+ (void)showErrorHUDWithText:(NSString *)alertText{
    dispatch_async(dispatch_get_main_queue(), ^{
    [ProgressHUD showError:alertText];
    });
}

+ (void)showHUDWithText:(NSString *)alertText{
    dispatch_async(dispatch_get_main_queue(), ^{
    [ProgressHUD show:alertText];
    });
}

+ (void)dismissHUD{
    [ProgressHUD dismiss];
}
#pragma mark -- Get TLAlertType By GIF File Name
+ (NSString *)gifFilePathWithGifAlertType:(TLAlertType)alertType{
    switch (alertType) {
        case TLAlertTypeSucc:
            return GIFAlertNetBlock;
            break;
        case TLAlertTypeNetBlock:
            return GIFAlertNetBlock;
            break;
        case TLAlertTypeUnknow:
            return GIFAlertNetBlock;
            break;
        case TLAlertTypeNoneData:
            return GIFAlertNetBlock;
            break;
            case TLAlertTypeLoading:
            return GIFAlertLoading;
            break;
        default:
            return GIFAlertNetBlock;
            break;
    }
}

+ (void)showAlertInView:(UIView *)view title:(NSString *)title cancleBtnTitle:(NSString *)ct destructiveBtnTitle:(NSString *)db completionWithAction:(ActionSheetBlock)completion{
    [TLAlertHelper sharedHelper].block = completion;
    [TLAlertHelper sharedHelper].sheet = [[LXActionSheet alloc] initWithTitle:title delegate:[TLAlertHelper sharedHelper] cancelButtonTitle:ct destructiveButtonTitle:db otherButtonTitles:@[@"确定"]];
    [[[TLAlertHelper sharedHelper] sheet] showInView:view];
}

#pragma mark -- LXActionSheetDelegate
- (void)didClickOnButtonIndex:(NSInteger)buttonIndex{
    if(self.block)
        self.block(buttonIndex);
}

- (void)didClickOnDestructiveButton{
    
}
- (void)didClickOnCancelButton{
    
}
@end
